﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace UBConDemo.ViewModels
{
    public class ViewModelBase : INotifyPropertyChanged
    {
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
        #region Constructors

        #endregion

        //------------------------------------------------------
        //
        //  Properties
        //
        //------------------------------------------------------
        #region Properties

        /// <summary>
        /// Gets or sets item's category.
        /// </summary>
        public string Category
        {
            get
            {
                return _category;
            }
            set
            {
                _category = value;
            }
        }

        /// <summary>
        /// Gets or sets item's title.
        /// </summary>
        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                bool _shouldRaiseEvent = string.Compare(_title, value) != 0;
                _title = value;
                if (_shouldRaiseEvent)
                {
                    OnPropertyChanged("Title");
                }
            }
        }
        #endregion

        //------------------------------------------------------
        //
        //  Overrides
        //
        //------------------------------------------------------
        #region Overrides

        /// <summary>
        /// Raises PropertyChanged event with specified propety.
        /// </summary>
        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------
        #region Public Methods
        #endregion

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------
        #region Internal Methods
        #endregion

        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------
        #region Private Methods

        #endregion

        //------------------------------------------------------
        //
        //  Event Handlers
        //
        //------------------------------------------------------
        #region Event Handlers
        #endregion

        //------------------------------------------------------
        //
        //  Fields
        //
        //-----------------------------------------------------
        #region Fields

        private string _category, _title;

        #endregion

        //------------------------------------------------------
        //
        //  Events
        //
        //-----------------------------------------------------
        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
